package com.smartthinking.CICPNL.home.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.webkit.WebView;

import com.smartthinking.CICPNL.R;

public class DocumentosDetalle extends Activity {
	/**
	 * @see android.app.Activity#onCreate(Bundle)
	 */
	/*
	* Add this in your Activity
	*/
	private final int MENU_ITEM_0 = 0;  
	Bundle extras;
	
	/** 
	 * Add menu items
	 * 
	 * @see android.app.Activity#onCreateOptionsMenu(android.view.Menu)
	 */
	public boolean onCreateOptionsMenu(Menu menu) {  
	    menu.add(0, MENU_ITEM_0, 0, "Compartir");  
	    return true;  
	}  
	 
	/** 
	 * Define menu action
	 * 
	 * @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem)
	 */
	public boolean onOptionsItemSelected(MenuItem item) {  
	    switch (item.getItemId()) {  
	        case MENU_ITEM_0:  
	        	shareRedes(extras.getString("url"));
	        	break;
		  default:
			// put your code here	  
	    }  
	    return false;  
	}
	
	
    protected void shareRedes(String cadena) {
        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, ""+cadena);
        sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Te envío la información del siguiente QR Code en CINTERMEX");
        startActivity(Intent.createChooser(sharingIntent, "Compartir mediante"));
    }
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.ui_documentos_detalle);
		
		extras = getIntent().getExtras();
		if(extras != null){
			WebView mWebView = (WebView) findViewById(R.id.webviewdoc);
			mWebView.getSettings().setJavaScriptEnabled(true);
			mWebView.loadUrl("https://docs.google.com/gview?embedded=true&url="+ extras.getString("url"));
		}else{
			
		}
		
		

	
	}
}
